#ifndef PlayMangent_H
#define PlayMangent_H

#include <QWidget>
#include <QImage>
#include <QPainter>
#include <QSlider>
#include <QLabel>
#include <QVBoxLayout>
#include "VideoDisplayWidget.h" // 用于获取视频帧
class PlayMangent;

class QVideoWidget : public QWidget {
    Q_OBJECT

public:
    explicit QVideoWidget(QWidget *parent = nullptr);
    ~QVideoWidget();

    void setPlayMangent(PlayMangent *playMangent);
    void setTotalTime(int Total_time);
    void setCurrentTimeLabel(QString time);

private:
    PlayMangent *m_playMangent;
    QImage m_currentFrame;
    QSlider *m_slider;
    QLabel *m_currentTimeLabel;
    QLabel *m_totalTimeLabel;
    QLabel *m_slashLabel;
    VideoDisplayWidget *m_videoWidget;
    QString formatTime(qint64 timeInMs);
private slots:
    void onNewFrame(const QImage &frame);
    void onSliderMoved(int position);
    void onPositionChanged(qint64 position);

//protected:
//    void paintEvent(QPaintEvent *event) override;
};

#endif // MAINWINDOW_H
